//
// Created by 11518 on 2024/11/22.
//

#include "sysinfo.h"
#include "sys/sysinfo.h"


bool SysInfo::update() {
    struct sysinfo si{};
    if(0!=sysinfo(&si)){
        return false;
    };
    m_UpTime = si.uptime;
    m_TotalRam = si.totalram;
    m_FreeRam = si.freeram;
    m_BufferRam = si.bufferram;
    m_ShareRam = si.sharedram;
    m_Load_1 = si.loads[0];
    m_Load_5 = si.loads[1];
    m_Load_15 = si.loads[2];
    m_TotalSwap = si.totalswap;
    m_FreeSwap = si.freeswap;
    m_Procs = si.procs;
    m_Pad = si.pad;

    return true;
}

u16 SysInfo::getProcs() const {
    return m_Procs;
}

long SysInfo::getUpTime() {
    return m_UpTime;
}

ulong SysInfo::getTotalRam() {
    return m_TotalRam;
}

ulong SysInfo::getFreeRam() {
    return m_FreeRam;
}

ulong SysInfo::getLoad1() {
    return m_Load_1;
}

ulong SysInfo::getLoad5() {
    return m_Load_5;
}

ulong SysInfo::getLoad15() {
    return m_Load_15;
}

ulong SysInfo::getBufferRam() const {
    return m_BufferRam;
}

ulong SysInfo::getShareRam() const {
    return m_ShareRam;
}

ulong SysInfo::getTotalSwap() const {
    return m_TotalSwap;
}

ulong SysInfo::getFreeSwap() const {
    return m_FreeSwap;
}

u16 SysInfo::getPad() const {
    return m_Pad;
}
